import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class BicycleTest {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void initialized() {
		Bicycle myBike = new Bicycle(21);

		int currentGears = myBike.getGears();

		assertTrue(currentGears == 21);

		int currentSpeed = myBike.getSpeed();

		assertTrue(currentSpeed == 0);

		int currentGear = myBike.getCurrentGear();

		assertTrue(currentGear == 1);
	}

	@Test
	public void pedalOnce() {
		Bicycle myBike = new Bicycle(21);

		myBike.pedal();

		int currentSpeed = myBike.getSpeed();

		assertTrue(currentSpeed == 1);
	}

	@Test
	public void pedalManyTimes() {
		Bicycle myBike = new Bicycle(21);

		myBike.pedal();
		int currentSpeed = myBike.getSpeed();
		assertTrue(currentSpeed == 1);

		myBike.pedal();
		currentSpeed = myBike.getSpeed();
		assertTrue(currentSpeed == 2);

		myBike.pedal();
		currentSpeed = myBike.getSpeed();
		assertTrue(currentSpeed == 3);

		myBike.pedal();
		currentSpeed = myBike.getSpeed();
		assertTrue(currentSpeed == 4);

		myBike.brake();
		currentSpeed = myBike.getSpeed();
		assertTrue(currentSpeed == 3);
	}

	@Test
	public void gearUpOnce() {
		Bicycle myBike = new Bicycle(21);

		myBike.shiftUp();

		int currentGear = myBike.getCurrentGear();

		assertTrue(currentGear == 2);
	}

	@Test
	public void gearUpMany() {
		Bicycle myBike = new Bicycle(21);

		myBike.shiftUp();

		int currentGear = myBike.getCurrentGear();

		assertTrue(currentGear == 2);

		myBike.shiftUp();
		currentGear = myBike.getCurrentGear();
		assertTrue(currentGear == 3);

		myBike.shiftUp();
		currentGear = myBike.getCurrentGear();
		assertTrue(currentGear == 4);
	}
	
	@Test
	public void gearUpLimitThree() {
		Bicycle myBike = new Bicycle(3);

		myBike.shiftUp();

		int currentGear = myBike.getCurrentGear();

		assertTrue(currentGear == 2);

		myBike.shiftUp();
		currentGear = myBike.getCurrentGear();
		assertTrue(currentGear == 3);

		myBike.shiftUp();
		currentGear = myBike.getCurrentGear();
		assertTrue(currentGear == 3);
	}
	
	@Test
	public void noShiftDownBelowFirstGear() {
		Bicycle myBike = new Bicycle(3);

		myBike.shiftDown();

		int currentGear = myBike.getCurrentGear();
		assertTrue(currentGear == 1);

	}
}
